﻿create PROCEDURE Sync.SP_CommitteeBankAccountMainBranchDeposites_SelectChanges
@LastRowVersion rowversion,
@FilterdColumn UNIQUEIDENTIFIER
AS 
BEGIN 
	SELECT 
        t.[CommitteeBankAccountMainBranchDepositID],
		g.[CommitteeBankAccountID],g.[DepositDate],g.[DepositAmount],g.[OperationNumber],
		t.IsDeleted,
		t.LastUpdatedDate
	FROM [dbo].[CommitteeBankAccountMainBranchDeposites] g RIGHT JOIN Sync.CommitteeBankAccountMainBranchDeposites_Tracking t  
    ON t.CommitteeBankAccountMainBranchDepositID = g.CommitteeBankAccountMainBranchDepositID 
    join CommitteeBankAccount cba on cba.CommitteeBankAccountID = g.CommitteeBankAccountID
	WHERE (@LastRowVersion IS NULL OR t.Version > @LastRowVersion)
	AND ((@FilterdColumn IS NULL) OR (cba.CommitteeID = @FilterdColumn))
    END











